package Interface;

import Book.BookList;

import java.util.Scanner;

/**
 * @Author YuanYuan
 * @Date 2022/5/18
 * @Time 10:42
 */
public class BorrowBook implements INterface {
    @Override
    public void work(BookList bookList) {
        System.out.println("借出图书");
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入要借图书的书名: ");
        String name = scanner.nextLine();
        for (int i = 0; i < bookList.getNumber(); i++) {
            if(bookList.getBooks(i).getName().equals(name)) {
                if(bookList.getBooks(i).isIsborrow() == true) {
                    System.out.println("这本书以被借出！");
                    return;
                }
                bookList.getBooks(i).setIsborrow(true);
                System.out.println("借书成功！");
                return;
            }
        }
        System.out.println("本图书馆没有这本书哦~");
        return;
    }
}
